<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
		<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
		<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
		<title>登陆</title>
		<script type="text/javascript">
			$(document).ready(function() {
				var timestamp = new Date().getTime();
				$("#encodeimg").attr("src", "check.do?time=" + timestamp);
			});

			function submit() {
				$.ajax({
					type: "post",
					url: "login.do",
					async: false,
					dataType: "json",
					data: {
						userid: $("#username").val(),
						userpass: $("#passwd").val(),
						encode: $("#encode").val()
					},
					success: function(data) {
						if(data.statue == "success") {
							alert("成功");
							document.location.href = "uploadpage.do";
						} else if(data.statue == "encodeingerror") {
							var timestamp = new Date().getTime();
							$("#encodeimg").attr("src", "check.do?time=" + timestamp);
							alert("验证码错误");
						} else {
							var timestamp = new Date().getTime();
							$("#encodeimg").attr("src", "check.do?time=" + timestamp);
							alert("账号或密码错误");
						}
					}
				});
			}
		</script>
	</head>

	<body>
		<div class="jumbotron">
			<div class="container">
				<h3>如果想要提交你的展示项目，请您先登陆此页面，如果无法登陆，请联系管理员</h3>
			</div>
		</div>
		<div class="container">
			<div class="form-horizontal">
				<div class="form-group">
					<label class="col-md-2 control-label">学号：</label>
					<div class="col-md-10">
						<input class="form-control" type="text" name="username" id="username">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">密码：</label>
					<div class="col-md-10">
						<input class="form-control" type="password" name="passwd" id="passwd">
					</div>
				</div>
				<div class="form-group row">
					<label for="inputPassword3" class="col-sm-2 control-label">Encode</label>
					<div class="col-sm-3">
						<input type="password" class="form-control" id="encode" placeholder="验证码">
					</div>
					<img id="encodeimg" />
				</div>
				<button class="col-md-offset-2 btn btn-default" onclick="submit()" type="submit">登陆</button>
			</div>
		</div>
	</body>

</html>